import 'package:environmental_les_app/common/style/colours.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

class SelectBottomDialog extends StatelessWidget {
  final String select1;
  final String select2;
  final VoidCallback callback1;
  final VoidCallback callback2;

  const SelectBottomDialog({
    super.key,
    required this.select1,
    required this.select2,
    required this.callback1,
    required this.callback2,
  });

  @override
  Widget build(BuildContext context) {
    KeyBoardUtils.hideKeyboard();
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        cardContainer(children: [
          buttonItem(
              title: select1,
              onTap: () {
                Get.back();
                callback1.call();
              }),
          const Divider(height: 1.0),
          buttonItem(
              title: select2,
              onTap: () {
                Get.back();
                callback2.call();
              }),
        ]),
        vGap10,
        cardContainer(children: [
          buttonItem(
            title: "取消",
            onTap: () => Get.back(),
          )
        ]),
        vGap10,
      ],
    );
  }

  /// 圆角卡片
  cardContainer({required List<Widget> children}) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.symmetric(horizontal: 20.0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10.0),
      ),
      child: Column(
        children: children,
      ),
    );
  }

  /// 按钮
  buttonItem({title, onTap}) {
    return InkWell(
      onTap: onTap,
      child: Container(
        constraints: const BoxConstraints(minHeight: 45.0),
        alignment: Alignment.center,
        child: Text(
          title ?? "",
          style: const TextStyle(
              fontSize: 14.0,
              color: Colours.text254,
              fontWeight: FontWeight.bold),
        ),
      ),
    );
  }
}
